package game;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.geom.Point2D;
import java.util.Random;

public class Particula extends GameObject {

	private float velocidade;
	private Point2D direcao;
	private boolean life;
	private float timeLife;
	private float timer;
	private String numero;
	public boolean getLife() {	return life;	}
	private Color cor;
	Font fonteParticula = new Font("Book Antiqua", Font.PLAIN, 12);
	Random random = new Random();
	
	public Particula(Point2D position, Point2D size, float velocidade, Point2D direcao, int numero) 
	{
		super(null, position, size, null, null);
		this.life = true;
		this.timeLife = 1f;
		this.direcao = direcao;
		this.velocidade = velocidade;
		this.numero = "" + numero;
		this.cor = new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256));
	}
	
	public void update()
	{
		timer += System.nanoTime() / 100000000000000.0f;
		if (timer > timeLife)
			life = false;
		super.setPosition(new Point2D.Double(	super.getPosition().getX() + (this.direcao.getX() * this.velocidade),
												super.getPosition().getY() + (this.direcao.getY() * this.velocidade)));
	}
	
	public void draw(Graphics g)
	{
		g.setColor(this.cor);
		g.setFont(fonteParticula);
		g.drawString(this.numero, (int)super.getPosition().getX(), (int)super.getPosition().getY());
	}
}
